package com.example.handlerdemo;

import android.app.Application;
import android.content.Context;

import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;

/**
 * Created by tangjiangxu on 9/25/17.
 */

public class MyApplication extends Application {
    private RefWatcher refWatcher;
    @Override
    public void onCreate() {
        super.onCreate();
        refWatcher = LeakCanary.install(this);   //初始化LeakCanry
    }

    /**
     * 得到RefWatcher对象，用于检测内存问题
     * @param context
     * @return
     */
    public static RefWatcher getRefWatcher(Context context) {
        return ((MyApplication)(context.getApplicationContext())).refWatcher;
    }
}
